home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 007 / lblcs.arc / KEY.DOC < prev    next >
Text File  |  1985-05-08  |  6KB  |  203 lines

  1. **************** interrupt driven routines *****************
  2.  
  3. ;--------------------------------------------------------------
  4. ;
  5. ; name        key_intercept - intercept hardware key interrupt
  6. ;
  7. ; synopsis    key_intercept();
  8. ;
  9. ; description    Intercepts the hardware keyboard interrupt.  You can
  10. ;        use this routine to gain absolute control over the 
  11. ;        keyboard.  The disadvantage is that you have to work
  12. ;        with scan codes directly, not nice ascii characters.
  13. ;        Up to 512 scan codes are buffered.
  14. ;
  15. ; notes
  16. ;        The key_nointercept routine MUST be called before
  17. ;        leaving your program, or the machine will hang.
  18. ;
  19. ;        You must not attempt to use any other routine that
  20. ;        reads the keyboard, or your program will hang.  This
  21. ;        routine absolutely intercepts the keyboard.
  22. ;
  23. ;        You are in control of the keyboard, but that means that
  24. ;        it is your responsibility to manage the state of the
  25. ;        shift keys, the caps lock, and numlock keys and any other
  26. ;        command keys, like the control key.
  27. ;
  28. ;        Each key returns two scan codes, one when pressed, one
  29. ;        when released.  The code returned when the key is pressed
  30. ;        is called a MAKE code, the one returned when a key is
  31. ;        released is called a BREAK code.  The BREAK code is 
  32. ;        the same as the make code, except that the high order bit
  33. ;        is set in the BREAK code.
  34. ;
  35. ;--------------------------------------------------------------     
  36.  
  37.  
  38.  
  39.  
  40. ;--------------------------------------------------------------
  41. ; name        key_nointercept - remove keyboard interception
  42. ;
  43. ; synopsis    VOID key_nointercept()
  44. ;
  45. ; description    Removes    the interrupt structure    installed by key_intercept.
  46. ;        Must be done before passing control to DOS, else your 
  47. ;        machine will hang.
  48. ;--------------------------------------------------------------
  49.  
  50.  
  51.  
  52.  
  53. ;--------------------------------------------------------------
  54. ; name        key_intbcnt - Return # chars in interrupt buffer
  55. ;
  56. ; synopsis    count = key_intbcnt();
  57. ;
  58. ; description    Returns the number of scan codes available in the
  59. ;        keyboard intercept interrupt buffer.
  60. ;
  61. ; notes        Call this to make sure that there are keystrokes
  62. ;        available before attempting to read a code out of
  63. ;        the buffer.  If there are no codes available, DO NOT
  64. ;        attempt to read the buffer.
  65. ;
  66. ;--------------------------------------------------------------  
  67.  
  68.  
  69.  
  70. ;--------------------------------------------------------------
  71. ;
  72. ; name        key_intbflush - Flush the interrupt buffer.
  73. ;
  74. ; synopsis    VOID key_intbflush()
  75. ;
  76. ; description    Flushes any key strokes in the keyboard interrupt
  77. ;        intercept buffer.
  78. ;
  79. ;--------------------------------------------------------------
  80.  
  81.  
  82. ;--------------------------------------------------------------
  83. ;
  84. ; name        key_intbread - get a char from the input buffer.
  85. ;
  86. ; synopsis    ch = key_intbread();
  87. ;
  88. ; description    returns the next character from the keyboard
  89. ;        interrupt intercept buffer. Assumes you have called
  90. ;        key_intbcnt to see if there are any characters to get.
  91. ;
  92. ; notes:
  93. ;        Will probably crash if called when the buffer is
  94. ;        empty.  Call key_intbcnt first to see if there is
  95. ;        anything available to read !!!!!!!!
  96. ;
  97. ;--------------------------------------------------------------
  98.  
  99.  
  100.  
  101. **************** Non-interrupt driven routines follow ***************
  102.  
  103.  
  104.  
  105. ;--------------------------------------------------------------
  106. ;
  107. ; name        key_flush    - flush keyboard buffer
  108. ;
  109. ; synopsis    VOID    key_flush()
  110. ;
  111. ; description    Flushes (clears out) the keyboard buffer.
  112. ;
  113. ;
  114. ;--------------------------------------------------------------
  115.  
  116.  
  117.  
  118. ;--------------------------------------------------------------
  119. ;
  120. ; name        key_getch -- read a char from the keyboard
  121. ;
  122. ; synopsis    int    ch;
  123. ;        ch = key_getch();
  124. ;        scan = ch >> 8;
  125. ;        ascii = ch & 255;
  126. ;
  127. ; description    Waits for a key to be pressed on the keyboard and
  128. ;        returns the character.  Removes character from input 
  129. ;        buffer.  Returns both ASCII char and scan code.
  130. ;        scan code is in the high 8 bits, ASCII in the low 8 bits.
  131. ; Notes:
  132. ;        arrow keys and some others return only scan codes. Shift
  133. ;        keys, control keys and some others do not show up at all
  134. ;         when using this function.
  135. ;
  136. ;--------------------------------------------------------------
  137.  
  138.  
  139.  
  140.  
  141. ;--------------------------------------------------------------
  142. ; name        key_scan - see if key is available from keyboard
  143. ;
  144. ; synopsis    ch = key_scan();
  145. ;
  146. ; description    Check the DOS keyboard buffer for characters available.
  147. ;        returns 0 if no characters area available, or character
  148. ;        and scan code in the same manner as key_getch().  Note
  149. ;        that this routine does not remove characters from the
  150. ;        buffer - you must use key_getch() to do that.  Several
  151. ;        calls to this routine will return the same character -
  152. ;        i.e. the first character available in keyboard buffer.
  153. ;
  154. ; Notes:
  155. ;        NOT identical to the CI-C86 library function of the 
  156. ;        same name, which returns EOF or 0xffff if no chars
  157. ;        are available.
  158. ;--------------------------------------------------------------
  159.  
  160.  
  161.  
  162.  
  163.  
  164. ;--------------------------------------------------------------
  165. ;
  166. ; name        key_shift - return shift and other indicators
  167. ;
  168. ; synopsis    int key_shift()
  169. ;
  170. ; description    Returns status of shift and other indicators.
  171. ;
  172. ;        st = key_shift();
  173. ;        The following are TRUE if Non - zero:
  174. ;
  175. ;        right_shift = st & 0x01;
  176. ;        left_shift  = st & 0x02;
  177. ;        control_key = st & 0x04;
  178. ;        alt_key     = st & 0x08;
  179. ;        scroll_lock = st & 0x10;
  180. ;        num_lock    = st & 0x20;
  181. ;        caps_lock   = st & 0x40;
  182. ;        insert_key  = st & 0x80;
  183. ;
  184. ; Notes:
  185. ;        The high byte return of this is unknown.  If you intend
  186. ;        to not use the examples shown above, mask the returned
  187. ;        value to remove the unknown:
  188. ;    
  189. ;         st = key_shift() & 255;     
  190. ;
  191. ;--------------------------------------------------------------
  192.  
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201.